package com.jh.channel.pojo.fastsilver;

import java.util.Objects;

import static com.google.common.base.Strings.isNullOrEmpty;

public enum RefundStatus {

    /** 待支付 */
    PENDING(0, "\u672a\u9000\u6b3e"),

    /** 待处理 */
    PROCESS(1, "\u9000\u6b3e\u4e2d"),

    /** 支付中 */
    SUCCESS(2, "\u9000\u6b3e\u6210\u529f"),
    ;
    final int value;
    final String desc;

    RefundStatus(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public int getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static RefundStatus of(String val) {
        return of(val, null);
    }

    public static RefundStatus of(String val, RefundStatus defaultStatus) {
        if (isNullOrEmpty(val)) {
            return defaultStatus;
        }
        val = val.toUpperCase();
        for (RefundStatus os : values()) {
            if (Objects.equals(os.getValue(), val)) {
                return os;
            }
        }
        return defaultStatus;
    }

}
